package Demo3;

public class Main10 {
   private static boolean isFinished=false;
    public static void main(String[] args) throws InterruptedException {
       // boolean isFinished=false;
        Thread t=new Thread(()->{
            while(!isFinished){
                try {
                    System.out.println("hello thread");
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread 结束");
        });
        t.start();
        Thread.sleep(3000);
        isFinished=true;
    }
}
